package com.gdufs.secondhandwebsite.dao;

import com.gdufs.secondhandwebsite.entity.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@SpringBootTest
@RunWith(SpringRunner.class)
public class testUserMapper {
    @Autowired
    private UserMapper userMapper;
    @Test
    public void insert() {
        User user = new User();
        user.setNickname("Admin1");
        user.setPassword("123456");
        Integer rows = userMapper.insert(user);
        System.out.println(rows);

    }
    @Test
    public void updatePasswordByUid() {
        Integer uid = 18;
        String password = "123456";
        Integer rows = userMapper.updatePasswordByUid(uid, password);
        System.out.println("rows=" + rows);
    }

    @Test
    public void findByUid() {
        Integer uid = 12;
        User result = userMapper.findByUid(uid);
        System.out.println(result);
    }

    @Test
    public void updateInfoByUid() {
        User user = new User();
        user.setUser_id(18);
        user.setSchool("广外");
        user.setMarjor("即可");
        user.setGrade("大二");
        user.setSex("女");
        user.setAge(45);
        user.setAddress("GDUFSsdf");
        Integer rows = userMapper.updateInfoByUid(user);
        System.out.println("rows=" + rows);
    }
    @Test
    public void findByUsername(){
       User result= userMapper.findByUsername("lu");
        System.out.println(result);
    }
}